package org.bt.common.validator.aspect;

import org.bt.common.constant.CommonConstant;
import org.bt.common.validator.notempty.*;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;

/**
 * NotEmpty
 * <p>
 * Created on 2020/1/9
 *
 * @author tongw
 */
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.TYPE_USE})
@Retention(RetentionPolicy.RUNTIME)
@Repeatable(NotEmpty.List.class)
@Documented
@Constraint(
        validatedBy = {
                NotEmptyValidatorForCharSequence.class,
                NotEmptyValidatorForCollection.class,
                NotEmptyValidatorForArray.class,
                NotEmptyValidatorForMap.class,
                NotEmptyValidatorForArraysOfBoolean.class,
                NotEmptyValidatorForArraysOfByte.class,
                NotEmptyValidatorForArraysOfChar.class,
                NotEmptyValidatorForArraysOfDouble.class,
                NotEmptyValidatorForArraysOfFloat.class,
                NotEmptyValidatorForArraysOfInt.class,
                NotEmptyValidatorForArraysOfLong.class,
                NotEmptyValidatorForArraysOfShort.class
        }
)
public @interface NotEmpty {

    String message() default CommonConstant.Valid.NOT_EMPTY;

    String name() default "";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

    @Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.TYPE_USE})
    @Retention(RetentionPolicy.RUNTIME)
    @Documented
    public @interface List {
        NotEmpty[] value();
    }
}
